package com.lam.common.components.redis.receiver;

import java.util.Map;

import com.lam.common.components.redis.constant.RedisConstants;
import com.lam.common.components.redis.listener.RedisListerer;
import com.lam.common.utils.SpringUtils;
import org.springframework.stereotype.Component;


@Component
public class RedisReceiver {


    /**
     * 接受消息并调用业务逻辑处理器
     *
     * @param params
     */
    public void onMessage(Map<String, Object> params) {
        Object handlerName = params.get(RedisConstants.HANDLER_NAME);
        RedisListerer messageListener = SpringUtils.getBean(handlerName.toString(), RedisListerer.class);
        if (messageListener != null) {
            messageListener.onMessage(params);
        }
    }

}
